import { resolve } from "path";
import { defineConfig } from "vite";
import WindiCSS from "vite-plugin-windicss";

import react from "@vitejs/plugin-react";

function pathResolve(dir: string) {
    return resolve(process.cwd(), ".", dir);
}

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [react(), WindiCSS()],

    resolve: {
        alias: [
            {
                find: "@",
                replacement: pathResolve("src") + "/",
            },
            {
                find: "#",
                replacement: pathResolve("types") + "/",
            },
        ],
        dedupe: ["vue"],
    },
    server: {
        proxy: {
            "/midway": {
                target: "http://localhost:7001",
                changeOrigin: true,
            },
        },
    },
});
